from ConstraintSatisfaction import ConstraintSatisfaction
from Room import Room
from Person import Person, Professions


def Main() :    
    InitRooms()
    InitNear()
    InitPersons()
    print("\n\nRunning Naive ConstraintSatisfaction\n")
    if not csp.Allocate() :
        print("No solution found")
    else :
        csp.ListAllocations()
    print("\n\nRunning Smart ConstraintSatisfaction\n")
    if not csp.Allocate(False) :
        print("No solution found")
    else:
        csp.ListAllocations()

def InitRooms() :
    csp.Rooms.append(Room("T1", 2, 5));
    csp.Rooms.append(Room("T2", 3, 2));
    csp.Rooms.append(Room("T3", 1, 3));
    csp.Rooms.append(Room("T4", 1, 3));
    csp.Rooms.append(Room("T5", 2, 5));
    csp.Rooms.append(Room("T6", 2, 5));
    csp.Rooms.append(Room("T7", 2, 5));

def InitNear() :
    csp.SetRoomNear("T1", [ "T2", "T7" ]);
    csp.SetRoomNear("T2", [ "T1", "T3", "T6" ]);
    csp.SetRoomNear("T3", [ "T2", "T4", "T5" ]);
    csp.SetRoomNear("T4", [ "T3", "T5" ]);
    csp.SetRoomNear("T5", [ "T6", "T4", "T3" ]);
    csp.SetRoomNear("T6", [ "T5", "T7", "T2" ]);
    csp.SetRoomNear("T7", [ "T6", "T1" ]);

def InitPersons() :
    csp.Persons.append(Person("A", Professions.Boss, True, 5));
    csp.Persons.append(Person("B", Professions.Secretary, False, 1));
    csp.Persons.append(Person("C", Professions.ItSupport, False, 2));
    csp.Persons.append(Person("D", Professions.Boss, True, 5));
    csp.Persons.append(Person("E", Professions.Secretary, False, 1));
    csp.Persons.append(Person("F", Professions.Worker, False, 3));
    csp.Persons.append(Person("G", Professions.Worker, False, 2));
    csp.Persons.append(Person("H", Professions.Worker, True, 0));
    csp.Persons.append(Person("I", Professions.Worker, True, 1));

csp = ConstraintSatisfaction()
Main()
